<?php

/* 
 *   RichComments! v0.1
 *   The Wordpress Plugin that lets your blog subscribers attach photos and videos
 *   to their comments
 *   
 *   Copyright (C) 2007 Stefano Verna <stefano.verna@gmail.com>
 *   
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 2 of the License, or
 *   (at your option) any later version.
 *   
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *   
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>.
 */

	require_once("services.php");
	$types=getServices();
	
	// if there is valid data to parse
	if (isset($_GET['site']) && strlen($_GET['site'])>0 && isset($_GET['site']) && strlen($_GET['site'])) {
		$site = $_GET['site'];
		$url = $_GET['url'];
		if (isset($types[$site])) {
			$fetcher = $types[$site]['dataFetcher'];
			$result = $fetcher($url);
			if ($result)
				echo "var processURL = { success: true, id: '".$result['id']."', thumbSrc: '".$result['thumb']."', previewSrc: '".$result['previewImage']."', pageURL: '".$result['pageURL']."', title: '".htmlspecialchars($result['title'])."',  requestedURL: '".$url."'};";
			else
				echo "var processURL = { success: false }";
				
			exit;
		}
	}
	
	// ouch!
	echo "var processURL = { success: false }";
	
?>